package algorithm.easy;

public class Solution28 {

    //输入：haystack = "hello", needle = "ll"
    //输出：2
    public static int strStr(String haystack, String needle) {
        if(needle.equals("")){
            return 0;
        }
        int len = needle.length();
        for(int i=0;i<haystack.length()-len;i++){
            if(haystack.substring(i,len+i).equals(needle)){
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args){
        String haystack = "hello", needle = "ll";
        System.out.println(strStr(haystack,needle));
    }
}
